package com.wang.pojo;

import lombok.Data;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

@Data
public class SendDemo {

    private String name;


    private String dataType;

    private String startHexStr;

    //计算机制
    private Integer numMade;

    //保留位数
    private Integer reserveNum;

    //字节大小端
    private String byteType = "BB";


    //读取数据的下标开始位置
    private Integer startSite;
    //读取数据的下标结束位置
    private Integer endSite;


    public static void main(String[] args) {

        List<SendDemo> sendDemoList = new ArrayList<>();
        SendDemo s1 = new SendDemo();
        s1.setName("测试1");
        s1.setStartHexStr("0603");
        SendDemo s2 = new SendDemo();
        s2.setName("测试2");
        s2.setStartHexStr("0601");
        sendDemoList.add(s1);
        sendDemoList.add(s2);
        for (SendDemo s : sendDemoList) {
            System.out.println(s.getName() + " " + s.getStartHexStr());
        }

        List<SendDemo> sendDemoList1 = search(sendDemoList);
        for (SendDemo s : sendDemoList1) {
            System.out.println(s.getName() + " " + s.getStartHexStr());
        }


    }


    // 方式4: 升序排列
    public static List<SendDemo> search(List<SendDemo> confDataList) {
        Collections.sort(confDataList, new Comparator<SendDemo>() {
            @Override
            public int compare(SendDemo o1, SendDemo o2) {
                return o1.getStartHexStr().compareTo(o2.getStartHexStr());
            }
        });
        return confDataList;
    }

}







